package com.lhf.springcloud.DAO;

import com.lhf.springcloud.Entity.StudentBasicInfo;
import com.lhf.springcloud.Entity.StudentInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface StudentDao {
    @Insert("insert into student_info (id,studentName,studentNumber,Department,major,grade,achievement,gender,idCard,infoJudge) values((select uuid()),#{studentName},#{studentNumber},#{department},#{major},#{grade},#{achievement},#{gender},#{idCard},#{infoJudge})")
    void addCourse(StudentInfo course);
    @Select("select id,studentName,studentNumber,department,major,grade,achievement,gender,idCard,infoJudge from student_info")
    List<StudentInfo> findAllData();
    @Select("select id,studentName,studentNumber,department,major,grade,achievement,gender,idCard,infoJudge from student_info where id=#{id}")
    StudentInfo findByStudentId(String id);
    @Update("UPDATE student_info SET ${dataName} = #{dataValue} WHERE id = #{id} ")
    void updateData(String dataValue,String id,String dataName);
    @Select("select count(id) studentName,gender from student_info where grade=#{year} group by gender")
    List<StudentInfo> findStudentByYear(String year);
    @Select("select studentName,idCard from student_basic_info where idCard=#{idCard}")
    List<StudentBasicInfo> findByStudentIdCard(String idCard);
    @Update("UPDATE student_info SET  infoJudge= #{falses} WHERE id = #{id}")
    void updateStudentStatus(String falses,String id);
}
